# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=netcat-openbsd
pkgver=1.226
pkgrel=0
pkgdesc="The TCP/IP swiss army knife. OpenBSD variant from debian."
url="https://packages.debian.org/sid/netcat-openbsd"
arch="all"
license="BSD-3-Clause"
makedepends="libbsd-dev"
subpackages="$pkgname-doc"
options="!check"
source="$pkgname-$pkgver.tar.gz::https://deb.debian.org/debian/pool/main/n/netcat-openbsd/netcat-openbsd_$pkgver.orig.tar.gz
	$pkgname-$pkgver-debian.tar.xz::https://deb.debian.org/debian/pool/main/n/netcat-openbsd/netcat-openbsd_$pkgver-1.debian.tar.xz
	b64.patch
	base64.c
	"

prepare() {
	default_prepare

	# debian keeps their patchset in their own folder
	while read -r patch; do
		patch -Np1 < "$srcdir"/debian/patches/"$patch"
	done < "$srcdir"/debian/patches/series

	# linux port requires b64_ntop
	cp "$srcdir"/base64.c .
	sed -i Makefile -e "/SRCS=/s;\(.*\);& base64.c;"
}

build() {
	make CFLAGS="$CFLAGS -DDEBIAN_VERSION=\"\\\"$pkgver\\\"\""
}

package() {
	install -Dm755 nc "$pkgdir"/usr/bin/nc
	install -Dm644 nc.1 "$pkgdir"/usr/share/man/man1/nc.openbsd.1
}

sha512sums="
1826086282236233757983619d423a538c253474e82050a55963bbc14f8d343432704e9748259873dcab75af03a708d2e2c05b3752e44bd2d198662f8dd5cd3a  netcat-openbsd-1.226.tar.gz
b7ab1a133cbfcca37864df4b2cc5b8d5fab25104670fb03a6ead538c6433064c736ec7c25b930a2c3ea28e19dc8279130f4465607174f1a4806b8d2f94596e74  netcat-openbsd-1.226-debian.tar.xz
c35ed4e10d0a8d312d8e730cafb8c69538183ce4af5a3cd2a1ceabfc58e009a23bf487507ef4aab5ad0617abf1dde6ac4be4dff6aac4bbb8091f2089cb6a8fe3  b64.patch
2d4b117397e6882b0f4357bb11ca1f520746c59e0305a58f8651582a9cff17f4c59cacb14ce93de1d0fe78db5ba7fd9096c0176afc61b2c715b0b9a0444c2b4f  base64.c
"
